package model

import (
	"github.com/lib/pq"
	"manager/model/entity"
)

// MessageCreateRequest 创建现场数据
type MessageCreateRequest struct {
	UserId int64 `json:"user_id"`

	PushType int `json:"push_type"`

	PushRange int `json:"push_range"`

	PushTime int `json:"push_time"`

	Title string `json:"title"`

	Content string `json:"content"`

	Delay int64 `json:"delay"`

	UserIds pq.Int64Array `json:"user_ids"`

	DeletedAt int64 `json:"deleted_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// MessageUpdateRequest 更新现场数据
type MessageUpdateRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	PushType *int `json:"push_type"`

	PushRange *int `json:"push_range"`

	PushTime *int `json:"push_time"`

	Title *string `json:"title"`

	Content *string `json:"content"`

	Delay *int64 `json:"delay"`

	DeletedAt *int64 `json:"deleted_at"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// MessageListRequest 列表现场数据
type MessageListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	PushType *int `json:"push_type"`

	PushRange *int `json:"push_range"`

	PushTime *int `json:"push_time"`

	Title *string `json:"title"`

	Content *string `json:"content"`

	Delay *int64 `json:"delay"`

	DeletedAt *int64 `json:"deleted_at"`

	UpdatedAt *int64 `json:"updated_at"`

	StartTime *int64 `json:"start_time"`
	EndTime   *int64 `json:"end_time"`

	TimeZone []int64 `json:"time_zone"`
}

// MessageListResponse 列表回包数据
type MessageListResponse struct {
	Total int            `json:"total"`
	List  []*MessageInfo `json:"list"`
}

// MessageInfoRequest 列表现场数据
type MessageInfoRequest struct {
	Id int64 `json:"id"`

	UserId *int64 `json:"user_id"`

	PushType *int `json:"push_type"`

	PushRange *int `json:"push_range"`

	PushTime *int `json:"push_time"`

	Title *string `json:"title"`

	Content *string `json:"content"`

	Delay *int64 `json:"delay"`

	DeletedAt *int64 `json:"deleted_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// MessageInfo 详细数据
type MessageInfo struct {
	Id int64 `json:"id"`

	UserId int64 `json:"user_id"`

	PushType int `json:"push_type"`

	PushRange int `json:"push_range"`

	PushTime int `json:"push_time"`

	Title string `json:"title"`

	Content string `json:"content"`

	Delay int64 `json:"delay"`

	DeletedAt int64 `json:"deleted_at"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// MessageDeleteRequest 删除现场数据
type MessageDeleteRequest struct {
	Id int64 `json:"id"`
}

// MessagesEntityToDto entity数据转换
func MessagesEntityToDto(messages []*entity.Message) []*MessageInfo {
	out := make([]*MessageInfo, 0, len(messages))
	for _, c := range messages {
		out = append(out, MessageEntityToDto(c))
	}
	return out
}

// MessageEntityToDto entity数据转换
func MessageEntityToDto(e *entity.Message) *MessageInfo {
	return &MessageInfo{

		Id: e.Id,

		UserId: e.UserId,

		PushType: e.PushType,

		PushRange: e.PushRange,

		PushTime: e.PushTime,

		Title: e.Title,

		Content: e.Content,

		Delay: e.Delay,

		DeletedAt: e.DeletedAt,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
